<template>
    <div style="background-color: #f9f9f9;width: 100%" v-bind:style="{height:iframeHeight+'px'}">
        <van-nav-bar
                title="我的邀请码"
                left-text="返回"
                left-arrow
                @click-left="onClickLeft"
        />
        <div style="padding: 20px;">
            <div style="
        border-radius: 10px;text-align: center;
        margin: 25px auto;
        background-color: #ffffff;box-shadow: 0px 0px 20px #ddd;padding-bottom:10px;">
                <span style="line-height: 50px;">扫一扫，邀请好友</span>
                <img :src="'http://api.yyw66.cn/api/user/Invitation/code?user_id='+user_id"
                     style="width: 100%;"
                />
            </div>

            <van-button size="large" @click="copyDownloadLink">复制APP下载链接</van-button>
        </div>
    </div>

</template>

<script>
    import Vue from 'vue'
    import {Toast} from 'vant';

    Vue.use(Toast);
    export default {
        data() {
            return {
                user_id: '',
                fixed: true,
                iframeHeight: ''
            }
        },
        methods: {
            onClickLeft() {
                this.$router.back()
            },
            copyDownloadLink() {
                var Context = plus.android.importClass("android.content.Context");
                var main    = plus.android.runtimeMainActivity();
                var clip    = main.getSystemService(Context.CLIPBOARD_SERVICE);
                plus.android.invoke(clip, "setText", "http://api.yyw66.cn/plugin/invite/register/index.html");
                Toast('app下载链接已复制');
            }
        },
        created() {
            this.user_id = JSON.parse(localStorage.getItem('user')).id
        },
        mounted() {
            this.iframeHeight = document.documentElement.clientHeight;
            // this.see(this.$route.query.url)
        }
    }
</script>

<style scoped>
    .title {
        border-bottom: 1px solid #BFBFC0;
    }
</style>
